From 627d8d282246045143e02ca87f2018d01a2ed590 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Mon, 12 Aug 2013 20:49:53 +0000 Subject: [PATCH] Checkpoint NEWQ code. Still not very happy with it. It's exposing all kinds of ugliness. --- gpsbabel/filterdefs.h | 3 +++ gpsbabel/netstumbler.cc | 12 ++++++++++-- gpsbabel/transform.cc | 7 +++++-- gpsbabel/waypt.cc | 27 +++++++++++++++------------ 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/gpsbabel/filterdefs.h b/gpsbabel/filterdefs.h index 6af9a747f..9650a2467 100644 --- a/gpsbabel/filterdefs.h +++ b/gpsbabel/filterdefs.h @@ -27,6 +27,9 @@ */ extern queue waypt_head; +#if NEWQ +extern QList waypt_list; +#endif typedef struct filter_vecs { filter_init f_init; diff --git a/gpsbabel/netstumbler.cc b/gpsbabel/netstumbler.cc index f4140dc3f..a48ea9193 100644 --- a/gpsbabel/netstumbler.cc +++ b/gpsbabel/netstumbler.cc @@ -292,8 +292,6 @@ fix_netstumbler_dupes(void) { int i, ct = waypt_count(), serial = 0; htable_t* htable, *bh; - queue* elem, *tmp; - extern queue waypt_head; const char* snptr; char* tmp_sn; unsigned long last_crc; @@ -303,8 +301,18 @@ fix_netstumbler_dupes(void) bh = htable; i = 0; +#if NEWQ + // Why, oh, why is this format running over the entire waypoint list and + // modifying it? This seems wrong. + extern QList waypt_list; + foreach(waypoint* waypointp, waypt_list) { + bh->wpt = waypointp; +#else + queue* elem, *tmp; + extern queue waypt_head; QUEUE_FOR_EACH(&waypt_head, elem, tmp) { bh->wpt = (waypoint*) elem; +#endif snptr = bh->wpt->shortname; tmp_sn = strlower(xstrdup(snptr)); bh->crc = get_crc32(tmp_sn, strlen(snptr)); diff --git a/gpsbabel/transform.cc b/gpsbabel/transform.cc index a8e57e207..f70e25e41 100644 --- a/gpsbabel/transform.cc +++ b/gpsbabel/transform.cc @@ -59,7 +59,6 @@ arglist_t transform_args[] = { static void transform_waypoints(void) { - queue *elem, *tmp; route_head *rte; rte = route_head_alloc(); @@ -71,9 +70,13 @@ transform_waypoints(void) track_add_head(rte); break; } - +#if NEWQ + foreach(waypoint* wpt, waypt_list) { +#else + queue *elem, *tmp; QUEUE_FOR_EACH(&waypt_head, elem, tmp) { waypoint *wpt = (waypoint *) elem; +#endif wpt = waypt_dupe(wpt); switch (current_target) { diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index 2a3ef1ee5..a990b8a5f 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -30,8 +30,6 @@ #include "garmin_fs.h" #include "session.h" -#define NEWQ 0 // Work in progress. - #if NEWQ QList waypt_list; queue waypt_head; // This is here solely to freak out the formats that are @@ -54,7 +52,9 @@ void waypt_init(void) { mkshort_handle = mkshort_new_handle(); -#if !NEWQ +#if NEWQ + waypt_list.clear(); +#else QUEUE_INIT(&waypt_head); #endif } @@ -433,14 +433,17 @@ waypt_free(waypoint *wpt) delete wpt; } -void -waypt_flush(queue *head) -{ #if NEWQ - foreach(waypoint* q, waypt_list) { - waypt_free(q); +void +waypt_flush(queue* head) { + while (!waypt_list.isEmpty()) { + waypt_free(waypt_list.takeFirst()); } +} #else +void +waypt_flush(queue *head) +{ queue *elem, *tmp; QUEUE_FOR_EACH(head, elem, tmp) { @@ -450,8 +453,8 @@ waypt_flush(queue *head) waypt_ct--; } } -#endif } +#endif void waypt_flush_all() @@ -475,8 +478,8 @@ waypt_backup(signed int *count, queue **head_bak) qbackup = (queue *) xcalloc(1, sizeof(*qbackup)); QUEUE_INIT(qbackup); #if NEWQ -// Why doe sthis code exist? -abort(); +// Why does this code exist? +//abort(); #else QUEUE_MOVE(qbackup, &waypt_head); QUEUE_INIT(&waypt_head); @@ -502,7 +505,7 @@ waypt_restore(signed int count, queue *head_bak) } #if NEWQ -abort(); +//abort(); #else waypt_flush(&waypt_head); QUEUE_INIT(&waypt_head); -- 2.30.2